package cn.com.shaom.learning.sb.batch.service;

import cn.com.shaom.learning.sb.batch.Person;
import org.springframework.batch.item.validator.ValidatingItemProcessor;
import org.springframework.batch.item.validator.ValidationException;

import java.util.Objects;

/**
 * ClassName: CvsItemProcessor
 * Description: 数据处理
 * Date: 2017/12/28 15:50 【需求编号】
 *
 * @author Shaom
 * @version V1.0.0
 */
public class CvsItemProcessor extends ValidatingItemProcessor<Person> {

    @Override
    public Person process(Person item) throws ValidationException {
        //需要执行父类方法，才会调用自定义的校验器
        super.process(item);

        // 简单的数据处理
        if (Objects.equals("汉族", item.getNation())) {
            item.setNation("01");
        } else {
            item.setNation("02");
        }
        return item;
    }
}
